const path = require('path')
function resolve(dir) {
  return path.join(__dirname, dir)
}
module.exports = {
  publicPath: "",
  outputDir: "dist",
  assetsDir: 'static',
  runtimeCompiler: true,
  lintOnSave: true,
  productionSourceMap: false,
  css: {
    loaderOptions: {
      less: {
        javascriptEnabled: true
      }
    }
  },
  devServer: {
    open: true,
    overlay: {
      warnings: false,
      errors: false
    },
    port: 9090
  },
  chainWebpack: config => {
    config.resolve.symlinks(true);
    // if (process.env.NODE_ENV === 'development') {
    //   config
    //     .plugin('webpack-bundle-analyzer')
    //     .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
    // }
    config.resolve.alias
      .set('@', resolve('./src'))
      .set('_', resolve('./src/framework'))
      .set('#', resolve('./src/apps'))
  },
  configureWebpack: config => {
    let optimization = {
      splitChunks: {
        chunks: 'initial',
        minSize: 0,
        minChunks: 1,
        name: true,
        cacheGroups: {
          settings: {
            name: 'settings',
            test: /settings/
          },
          vendors: {
            name: 'vendors',
            test: /[\\/]node_modules[\\/]/,
            chunks: 'all',
            priority: -10
          }
        }
      }
    }
    Object.assign(config, {
      optimization
    })
  }
};
